from songmanager import SongManager , Part
import instruments
from timings import StandardTiming , BehindTheBeat , BangOn
from velocities  import StandardVelocity

s = SongManager()
s.setBPM( 120 )
s.definePattern(  "BD1" , "X---")
#s.definePattern(  "BD1" , "X---------------")
s.definePattern(  "BD2" , "X-x-")
s.definePattern("BD3" , "X--xx---")
s.definePattern("BD4" , "X---xx--" )
s.definePattern("BD5" , "X-x-x-")
s.definePattern("FT1" , "----x---")
s.definePattern(  "SD1" , "--x-")
s.definePattern(  "SD2" , "-x-x")
s.definePattern( "SD3" , "-xx-xx-xx-xx")
s.definePattern( "T1","x-----------")
s.definePattern( "T2","---x-----x--")
s.definePattern( "HH1" , "X---x---x---x---")
s.definePattern( "HH2" , "X-x-x-x-x-x-x-x-")
s.defineInstrument( "BD" ,  instruments.GMDrumInstrument( "Bass Drum" ) , BangOn(  ) , StandardVelocity( 120 , 80 , 10 ) )
s.defineInstrument( "FT" ,  instruments.GMDrumInstrument( "Low Tom" ) , BangOn(  ) , StandardVelocity( 120 , 80 , 10 ) )
s.defineInstrument( "T1" ,  instruments.GMDrumInstrument( "Low Mid Tom" ) , BangOn(  ) , StandardVelocity( 120 , 80 , 10 ) )
s.defineInstrument( "T2" ,  instruments.GMDrumInstrument( "Hi Mid Tom" ) , BangOn(  ) , StandardVelocity( 120 , 80 , 10 ) )
s.defineInstrument( "SD" ,  instruments.GMDrumInstrument( "Electric Snare" ) , BehindTheBeat( normal=0.01 , deviation=0.001 ) ,StandardVelocity( 120 , 80 , 10 ) )
s.defineInstrument( "HH" ,  instruments.GMDrumInstrument( "Closed Hi Hat" ) ,  BangOn( ) ,  StandardVelocity( 120 , 80 , 10 ))
s.defineTrack( "one" , 3 )


s.defineInstrument( "piano"  , instruments.SequenceInstrument( [ "c4" , "d#4" , "f3" , "d4"  , "d3" ] ) , BehindTheBeat( normal=0.01 , deviation=0.001 ) ,StandardVelocity( 120 , 80 , 10 ) )
s.definePattern( "piano1" , "X-xx-x-xxxxx-x" )
s.defineTrack( "two" , 0 )

p = Part() 
p["BD"].addPattern( "BD1" ,5 )
p["BD"].addPattern( "BD2" ,3 )
p["BD"].addPattern( "BD3" ,4 )
p["BD"].addPattern( "BD4" ,4 )
p["SD"].addPattern( "SD1" ,4 )
p["SD"].addPattern( "SD2" ,12 )
p["HH"].addPattern("HH1" , 4 )
p["HH"].addPattern( "HH2" ,12 )

p3=Part()
p3["piano"].addPattern( "piano1" , 10 )

p2= Part()
p2["BD"].addPattern("BD5",4)
p2["FT"].addPattern("FT1",4)
p2["SD"].addPattern("SD3" , 4 )
p2["T1"].addPattern("T1",4)
p2["T2"].addPattern("T2",4)

s["one"].addPart( p )
s["one"].addPart( p2 )
s["two"].addPart( p3 )
s.run()
